package lew.bing.exp.hys;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

import java.util.concurrent.TimeUnit;

/**
 * Created by 刘国兵 on 2018/7/15.
 */
public class HystrixCommandTest extends HystrixCommand<String>{

    protected HystrixCommandTest(HystrixCommandGroupKey group) {
        super(group,4000);
    }

    public static void main(String[] args) {
        HystrixCommand command = new HystrixCommandTest(HystrixCommandGroupKey.Factory.asKey("hello"));
        Object execute = command.execute();
        System.out.println(execute);
    }

    @Override
    protected String run() throws Exception {
        TimeUnit.SECONDS.sleep(3);
        return "Hello World";
    }
}
